]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Remove broken ShellAppSystem API and all consumers
authorColin Walters <walters@verbum.org>
Thu, 10 Mar 2011 17:19:10 +0000 (12:19 -0500)
committerColin Walters <walters@verbum.org>
Wed, 16 Mar 2011 19:07:22 +0000 (15:07 -0400)
In commit 9bd22dc0, I introduced an API to load an arbitrary
.desktop file, not necessarily from the menu path.  It turns
out this function was broken because it created ShellApp instances
that were *different* from ones that were cached normally.

As far as I can tell, we didn't initially use it.  Then later
Util.spawnDesktop was created which used this function.

Remove this broken function and all callers; if we're loading
.desktop files from *outside* the menu path, we can look at
readding.

This patch also kills off Util.spawnDesktop in favor of callers
talking to ShellAppSystem directly, now that the latter reports
errors.

https://bugzilla.gnome.org/show_bug.cgi?id=644402

js/misc/util.js
js/ui/dateMenu.js
js/ui/status/accessibility.js
js/ui/status/power.js
js/ui/status/volume.js
js/ui/statusMenu.js
src/shell-app-system.c
src/shell-app-system.h

index 1bc1a72838482383d9366ffa3b64d3115d5a7adb..1112bef212aaf69b9930499dfc141de4ac59526a 100644 (file)
@@ -55,20 +55,6 @@ function spawnCommandLine(command_line) {
     }
 }
 
-// spawnDesktop:
-// @id: a desktop file ID
-//
-// Spawns the desktop file identified by @id using startup notification,
-// etc, handling any errors that occur when trying to find or start
-// the program.
-function spawnDesktop(id) {
-    try {
-        trySpawnDesktop(id);
-    } catch (err) {
-        _handleSpawnError(id, err);
-    }
-}
-
 // trySpawn:
 // @argv: an argv array
 //
@@ -116,33 +102,6 @@ function trySpawnCommandLine(command_line) {
     trySpawn(argv);
 }
 
-// trySpawnDesktop:
-// @id: a desktop file ID
-//
-// Spawns the desktop file identified by @id using startup notification.
-// On error, throws an exception.
-function trySpawnDesktop(id) {
-    let app;
-
-    // shell_app_system_load_from_desktop_file() will end up returning
-    // a stupid error message if the desktop file doesn't exist, but
-    // that's the only case it returns an error for, so we just
-    // substitute our own error in instead
-    try {
-        app = Shell.AppSystem.get_default().load_from_desktop_file(id + '.desktop');
-    } catch (err) {
-        throw new Error(_("No such application"));
-    }
-
-    try {
-        app.launch();
-    } catch(err) {
-        // see trySpawn
-        err.message = err.message.replace(/.*\((.+)\)/, '$1');
-        throw err;
-    }
-}
-
 function _handleSpawnError(command, err) {
     let title = _("Execution of '%s' failed:").format(command);
     Main.notifyProblem(title, err.message);
index 6af0b68f561b4aa7ffe47b99e327e8805aa1266e..c0c8cea4e9195238c8abba1a5b58a17c9a9b828f 100644 (file)
@@ -200,7 +200,8 @@ DateMenuButton.prototype = {
 
     _onPreferencesActivate: function() {
         this.menu.close();
-        Util.spawnDesktop('gnome-datetime-panel');
+        let app = Shell.AppSystem.get_default().get_app('gnome-datetime-panel.desktop');
+        app.activate(-1);
     },
 
     _onOpenCalendarActivate: function() {
index 67b019ec8c7a5e6a56173c44eeeeb77cd48d7e43..b9cf7230abab8254a9e51b40a5f430c1bf54be53 100644 (file)
@@ -91,7 +91,8 @@ ATIndicator.prototype = {
 
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this.menu.addAction(_("Universal Access Settings"), function() {
-            Util.spawnDesktop('gnome-universal-access-panel');
+            let app = Shell.AppSystem.get_default().get_app('gnome-universal-access-panel.desktop');
+            app.activate(-1);
         });
     },
 
index fabb181877390959538cede61a55b91e6c3175eb..ca41f3a71f22c90242a0720bb6e94fd38fa9e033 100644 (file)
@@ -83,7 +83,8 @@ Indicator.prototype = {
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
 
         this.menu.addAction(_("Power Settings"),function() {
-            Util.spawnDesktop('gnome-power-panel');
+            let app = Shell.AppSystem.get_default().get_app('gnome-power-panel.desktop');
+            app.activate(-1);
         });
 
         this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
index 36aa65d122903364e5dbe864be403cebe586c712..29ffcee76acf9b4c85cc02c46b9c09756bf22b11 100644 (file)
@@ -64,7 +64,8 @@ Indicator.prototype = {
 
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this.menu.addAction(_("Sound Settings"), function() {
-            Util.spawnDesktop('gnome-sound-panel');
+            let app = Shell.AppSystem.get_default().get_app('gnome-sound-panel.desktop');
+            app.activate(-1);
         });
 
         this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
index 2a04506dbdd44a3ef24b3b1aa1333dbcce25eb1e..26a4fe46a4e5c0282ce2a15f941eff5eaaa593f1 100644 (file)
@@ -190,12 +190,14 @@ StatusMenuButton.prototype = {
 
     _onMyAccountActivate: function() {
         Main.overview.hide();
-        Util.spawnDesktop('gnome-user-accounts-panel');
+        let app = Shell.AppSystem.get_default().get_app('gnome-user-accounts-panel.desktop');
+        app.activate(-1);
     },
 
     _onPreferencesActivate: function() {
         Main.overview.hide();
-        Util.spawnDesktop('gnome-control-center');
+        let app = Shell.AppSystem.get_default().get_app('gnome-control-center.desktop');
+        app.activate(-1);
     },
 
     _onLockScreenActivate: function() {
index 519a83010e5878859e7dba88f36fa9eb7aeba3b0..9012540a2ec69474feb9945789e806b47d20c346 100644 (file)
@@ -159,20 +159,6 @@ shell_app_info_new_from_window (MetaWindow *window)
   return info;
 }
 
-static ShellAppInfo *
-shell_app_info_new_from_keyfile_take_ownership (GKeyFile   *keyfile,
-                                                const char *path)
-{
-  ShellAppInfo *info;
-
-  info = g_slice_alloc0 (sizeof (ShellAppInfo));
-  info->type = SHELL_APP_INFO_TYPE_DESKTOP_FILE;
-  info->refcount = 1;
-  info->keyfile = keyfile;
-  info->keyfile_path = g_strdup (path);
-  return info;
-}
-
 static void shell_app_system_class_init(ShellAppSystemClass *klass)
 {
   GObjectClass *gobject_class = (GObjectClass *)klass;
@@ -576,44 +562,6 @@ _shell_app_system_register_app (ShellAppSystem   *self,
   g_object_weak_ref (G_OBJECT (app), shell_app_system_on_app_weakref, ref);
 }
 
-ShellAppInfo *
-shell_app_system_load_from_desktop_file (ShellAppSystem   *system,
-                                         const char       *filename,
-                                         GError          **error)
-{
-  ShellAppInfo *appinfo;
-  GKeyFile *keyfile;
-  char *full_path = NULL;
-  gboolean success;
-
-  keyfile = g_key_file_new ();
-
-  if (strchr (filename, '/') != NULL)
-    {
-      success = g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, error);
-      full_path = g_strdup (filename);
-    }
-  else
-    {
-      char *app_path = g_build_filename ("applications", filename, NULL);
-      success = g_key_file_load_from_data_dirs (keyfile, app_path, &full_path,
-                                                G_KEY_FILE_NONE, error);
-      g_free (app_path);
-    }
-
-  if (!success)
-    {
-      g_key_file_free (keyfile);
-      g_free (full_path);
-      return NULL;
-    }
-
-  appinfo = shell_app_info_new_from_keyfile_take_ownership (keyfile, full_path);
-  g_free (full_path);
-
-  return appinfo;
-}
-
 /**
  * shell_app_system_create_from_window:
  *
@@ -1386,12 +1334,23 @@ shell_app_info_launch_full (ShellAppInfo *info,
   shell_app = shell_app_system_get_app (shell_app_system_get_default (),
                                         shell_app_info_get_id (info));
 
-  ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris,
-                                                   G_APP_LAUNCH_CONTEXT (context),
-                                                   G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
-                                                   NULL, NULL,
-                                                   _gather_pid_callback, shell_app,
-                                                   error);
+  /* In the case where we know an app, we handle reaping the child internally,
+   * in the window tracker.
+   */
+  if (shell_app != NULL)
+    ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris,
+                                                     G_APP_LAUNCH_CONTEXT (context),
+                                                     G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+                                                     NULL, NULL,
+                                                     _gather_pid_callback, shell_app,
+                                                     error);
+  else
+    ret = g_desktop_app_info_launch_uris_as_manager (gapp, uris,
+                                                     G_APP_LAUNCH_CONTEXT (context),
+                                                     G_SPAWN_SEARCH_PATH,
+                                                     NULL, NULL,
+                                                     NULL, NULL,
+                                                     error);
 
   g_object_unref (G_OBJECT (gapp));
 
index 3b615cecb3cfde4a3c82dc13e25ca5a9bed33998..b53c78d6d5bff33ca01fd3625a0293a17bd3733c 100644 (file)
@@ -81,9 +81,6 @@ ShellApp       *shell_app_system_get_app_for_window        (ShellAppSystem  *sel
 ShellApp       *shell_app_system_lookup_heuristic_basename (ShellAppSystem  *system,
                                                             const char      *id);
 
-ShellAppInfo   *shell_app_system_load_from_desktop_file    (ShellAppSystem  *system,
-                                                            const char      *filename,
-                                                            GError         **error);
 ShellAppInfo   *shell_app_system_create_from_window        (ShellAppSystem  *system,
                                                             MetaWindow      *window);